using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;


namespace Scopa.Menu
{

  
  /// <summary>
  /// This is a game component that implements IUpdateable.
  /// </summary>
  public class Button // : Microsoft.Xna.Framework.DrawableGameComponent
  {

    public Texture2D texture { get; set; }
    public Rectangle bounds;
    public string message { get; set; }
    public SpriteFont spriteFont { get; set; }
    public Color color { get; set; }
    public Color textColor { get; set; }    
    public float scale {get; set; }
    public bool touched { get; set; }
    public Color TouchColor { get; set; }
    

    SpriteBatch spriteBatch;
    
    // --- Constructors ---

    public Button(Game game) // : base(game)
    {
      this.spriteBatch = game.GetScopaContext().SpriteBatch;
    }
    
    //Costruttore con parametro scalatura del testo
    public Button(Game game, string filepath, Rectangle bounds, Color color, string fontPath, string message, Color textColor, float scale)
    // : base(game)
    {
      if ((filepath != null) && (filepath.Length != 0))
        this.texture = game.Content.Load<Texture2D>(filepath);
      this.bounds = bounds;
      this.spriteFont = game.Content.Load<SpriteFont>(fontPath);
      this.message = message;
      this.touched = false;
      this.spriteBatch = game.GetScopaContext().SpriteBatch;
      this.color = color;
      this.textColor = textColor;
      this.scale = scale;

    }

    //Costruttore con parametro Color dell'effetto "premuto"
    public Button(Game game, string filepath, Rectangle bounds, Color color, string fontPath, string message, Color textColor, Color TouchColor)
    // : base(game)
    {
      if ((filepath != null) && (filepath.Length != 0))
        this.texture = game.Content.Load<Texture2D>(filepath);
      this.bounds = bounds;
      this.spriteFont = game.Content.Load<SpriteFont>(fontPath);
      this.message = message;
      this.touched = false;
      this.TouchColor = TouchColor;
      this.spriteBatch = game.GetScopaContext().SpriteBatch;
      this.color = color;
      this.textColor = textColor;
      this.scale = 1.0f;

    }

    //Costruttore con parametri base
    public Button(Game game, string filepath, Rectangle bounds, Color color, string fontPath, string message, Color textColor)
    // : base(game)
    {
      if ((filepath != null) && (filepath.Length != 0))
        this.texture = game.Content.Load<Texture2D>(filepath);
      this.bounds = bounds;
      this.spriteFont = game.Content.Load<SpriteFont>(fontPath);
      this.message = message;
      this.touched = false;
      this.TouchColor = TouchColor;
      this.spriteBatch = game.GetScopaContext().SpriteBatch;
      this.color = color;
      this.textColor = textColor;
      this.scale = 1.0f;
      
        
    }

    public Button(Game game, string filepath, Rectangle bounds, string fontPath, string message)
      : this(game, filepath, bounds, Color.White, fontPath, message, Color.Black, 1.0f) { }

    

    /// <summary>
    /// Check if a given point is within the button bounds
    /// </summary>
    /// <param name="tapPosition">The point to check</param>
    /// <returns>True if the point is within the button bounds, false otherwise</returns>
    public bool IsInBounds(Point point)
    {

      if (bounds.Contains(point))
        return true;
      return false;
    }
  }
}
